﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Net.Mail;
namespace Fcom.VNInsurance.Web.Infrastructure
{
    public static class SMTPSendMail
    {
        public static bool SendOneEmail(Fcom.VNInsurance.Web.Models.ConfigSMTP config, string mailto, string subject, string content,bool ishtml)
        {
            MailMessage mailMessage = new MailMessage();
            SmtpClient mailClient = new SmtpClient(config.MailSMTP, config.Port);
            mailClient.Timeout = 15000;
        
            mailClient.Credentials = new NetworkCredential(config.UserID, config.Password);
            mailClient.EnableSsl = config.UseSSL;
            mailMessage.IsBodyHtml = true;
            mailMessage.From = new MailAddress(config.UserID);
            mailMessage.Subject = subject;
            mailMessage.Body = content;
            mailMessage.To.Add(mailto);
            try
            {
                mailClient.Send(mailMessage);
                return true;
            }
            catch 
            {
                return false;
            }
         
        }
    }
}